<template>
  <div>
    <el-row :gutter="10">
      <el-col :span="6">
          <el-button type="primary" size="mini" @click="isCollapsed =!isCollapsed">切换</el-button>
        <el-menu
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
          unique-opened
          :default-openeds="['/basic']"
          default-active="/layout"
          :collapse="isCollapsed"
          @select="handleSelect"
          router 
        >
          <el-submenu index="/basic">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>基本组件</span>
            </template>
            <el-menu-item index="/layout">布局</el-menu-item>
            <el-menu-item index="/icon">图标</el-menu-item>
            <el-menu-item index="/button">按钮</el-menu-item>
          </el-submenu>

          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span>导航2</span>
            </template>
            <el-menu-item index="2-1">选项1</el-menu-item>
            <el-menu-item index="2-2">选项2</el-menu-item>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title">
                <i class="el-icon-setting"></i>
                <span>导航3</span>
            </template>
            <el-menu-item index="3-1">选项1</el-menu-item>
            <el-menu-item index="3-2">选项2</el-menu-item>
          </el-submenu>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: "NavMenu",
  methods:{
      handleSelect(index,indexPath){
          console.log(index);
          console.log(indexPath);
      }
  },
  data(){
      return{
          isCollapsed:false
      }
  }
};
</script>

<style>
</style>